package com.ll.beautymall.ui.home.allbuy.presenter;

import com.ll.beautymall.bean.HomeAllBuy;
import com.ll.beautymall.ui.home.allbuy.view.IAllBuyView;
import com.ll.beautymall.ui.home.allbuy.model.AllBuyBiz;
import com.ll.beautymall.ui.home.allbuy.model.OnGetAllBuyLisenter;

import java.util.HashMap;

/**
 * Created by Administrator on 2016/10/24.
 */
public class AllBuyPresenter {
    private AllBuyBiz allBuyBiz;
    private IAllBuyView allBuyView;

    public AllBuyPresenter(IAllBuyView view) {
        allBuyView = view;
        allBuyBiz = new AllBuyBiz();
    }

    public void setAllBuyData(final boolean isMore, HashMap<String, String> parameters) {
        allBuyBiz.getAllBuyData(parameters, new OnGetAllBuyLisenter() {
            @Override
            public void onSucced(HomeAllBuy homeAllBuy) {
                if (homeAllBuy != null) {
                    if (isMore) {
                        allBuyView.addAllBuyData(homeAllBuy);
                    } else {
                        allBuyView.setAllBuyData(homeAllBuy);
                    }
                }
            }

            @Override
            public void onFailed(String errorMsg) {
                allBuyView.showErrorMsg(errorMsg);
            }
        });
    }
}
